<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>{$meta_title}-狂雨小说CMS</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <link rel="stylesheet" href="__ADMIN__/css/admin.css">
    </head>
    <body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-form">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <table class="layui-table">
                                <colgroup>
                                    <col>
                                    <col width="150">
                                    <col width="150">
                                    <col width="150">
                                    <col width="200">
                                    <col width="150">
                                    <col width="180">
                                </colgroup>
                                <thead>
                                    <tr>
                                        <th>备份名称</th>
                                        <th>卷数</th>
                                        <th>压缩</th>
                                        <th>数据大小</th>
                                        <th>备份时间</th>
                                        <th>状态</th>
                                        <th><div align="center">操作</div></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {notempty name="list"}
                                    {volist name="list" id="data"}
                                    <tr>
                                        <td>{$data.time|date='Ymd-His'}</td>
                                        <td>{$data.part}</td>
                                        <td>{$data.compress}</td>
                                        <td>{$data.size|format_bytes}</td>
                                        <td>{$key}</td>
                                        <td>-</td>
                                        <td align="center">
                                            <a class="layui-btn layui-btn-normal layui-btn-xs db-import" href="{:url('import',['time'=>$data['time']])}"><i class="layui-icon layui-icon-console"></i>还原</a> 
                                            <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="admin_del(this,'{:url('del',['time'=>$data['time']])}')" href="javascript:;"><i class="layui-icon layui-icon-delete"></i>删除</a>
                                        </td>
                                    </tr>
                                    {/volist}
                                    {/notempty}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="__STATIC__/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/admin.js"></script>
    <script type="text/javascript">
        $(".db-import").click(function(){
            var self = this, status = ".";
            $.get(self.href, success, "json");
            window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
            return false;
        
            function success(data){
                if(data.code){
                    if(data.gz){
                        data.msg += status;
                        if(status.length === 5){
                            status = ".";
                        } else {
                            status += ".";
                        }
                    }
                    $(self).parent().prev().text(data.msg);
                    if(data.data.part){
                        $.get(self.href, 
                            {"part" : data.data.part, "start" : data.data.start}, 
                            success, 
                            "json"
                        );
                    }  else {
                        window.onbeforeunload = function(){ return null; }
                    }
                } else {
                    layer.msg(data.msg);
                }
            }
        });
    </script>
    </body>
</html>